package com.ruoyi.exam.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.exam.mapper.TActivityRecordsMapper;
import com.ruoyi.exam.domain.TActivityRecords;
import com.ruoyi.exam.service.ITActivityRecordsService;
import com.ruoyi.system.mapper.SysUserMapper;

/**
 * 访问审批记录Service业务层处理
 * 
 * @author FeiW
 * @date 2025-01-26
 */
@Service
public class TActivityRecordsServiceImpl implements ITActivityRecordsService 
{
    @Autowired
    private TActivityRecordsMapper tActivityRecordsMapper;

    @Autowired
    private SysUserMapper sysUserMapper;

    /**
     * 查询访问审批记录
     * 
     * @param id 访问审批记录主键
     * @return 访问审批记录
     */
    @Override
    public TActivityRecords selectTActivityRecordsById(Long id)
    {
        return tActivityRecordsMapper.selectTActivityRecordsById(id);
    }

    /**
     * 查询访问审批记录列表
     * 
     * @param tActivityRecords 访问审批记录
     * @return 访问审批记录
     */
    @Override
    public List<TActivityRecords> selectTActivityRecordsList(TActivityRecords tActivityRecords)
    {
        List<TActivityRecords> tActivityRecordsList = tActivityRecordsMapper
                .selectTActivityRecordsList(tActivityRecords);
        // for 循环遍历tActivityRecordsList
        for (TActivityRecords tActivityRecords2 : tActivityRecordsList) {
            tActivityRecords2.setUserName(sysUserMapper.selectUserById(Long.valueOf(tActivityRecords2.getUserId())).getNickName());
        }
        return tActivityRecordsList;
    }

    /**
     * 新增访问审批记录
     * 
     * @param tActivityRecords 访问审批记录
     * @return 结果
     */
    @Override
    public int insertTActivityRecords(TActivityRecords tActivityRecords)
    {
        return tActivityRecordsMapper.insertTActivityRecords(tActivityRecords);
    }

    /**
     * 修改访问审批记录
     * 
     * @param tActivityRecords 访问审批记录
     * @return 结果
     */
    @Override
    public int updateTActivityRecords(TActivityRecords tActivityRecords)
    {
        return tActivityRecordsMapper.updateTActivityRecords(tActivityRecords);
    }

    /**
     * 批量删除访问审批记录
     * 
     * @param ids 需要删除的访问审批记录主键
     * @return 结果
     */
    @Override
    public int deleteTActivityRecordsByIds(Long[] ids)
    {
        return tActivityRecordsMapper.deleteTActivityRecordsByIds(ids);
    }

    /**
     * 删除访问审批记录信息
     * 
     * @param id 访问审批记录主键
     * @return 结果
     */
    @Override
    public int deleteTActivityRecordsById(Long id)
    {
        return tActivityRecordsMapper.deleteTActivityRecordsById(id);
    }
}
